package net.maku.module.organization.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.utils.PageResult;
import net.maku.framework.common.utils.Result;
import net.maku.module.organization.convert.RoleConvert;
import net.maku.module.organization.convert.RoleStaffConvert;
import net.maku.module.organization.convert.WorkplaceConvert;
import net.maku.module.organization.entity.RoleStaffEntity;
import net.maku.module.organization.query.RoleStaffQuery;
import net.maku.module.organization.service.RoleStaffService;
import net.maku.module.organization.vo.RoleStaffVO;
import net.maku.module.organization.vo.RoleVO;
import net.maku.module.staff.convert.StaffConvert;
import net.maku.module.staff.vo.StaffVO;
import net.maku.newbase.NewBaseController;
import net.maku.newbase.NewQuery;
import net.maku.newbase.PageParam;

import org.springframework.web.bind.annotation.*;

/**
* 业务_角色
*
* @author     
*/
@RestController
@RequestMapping("nb/role_staff")
@Tag(name="业务_角色")
@AllArgsConstructor
public class RoleStaffController extends NewBaseController<RoleStaffService, RoleStaffEntity> {

    @GetMapping("page")
    @Operation(summary = "分页 展示列表")
    public Result<PageResult<RoleStaffVO>> pageByRoleId(PageParam page, RoleStaffQuery roleStaffQuery){

        IPage iPage=entityService.pageByRoleId(page.b(), roleStaffQuery);

        return Result.ok(new PageResult<>(iPage.getRecords(), iPage.getTotal()));
    }

    @GetMapping("pageStaff")
    @Operation(summary = "分页 选择员工")
    public Result<PageResult<StaffVO>> pageStaff(PageParam page, RoleStaffQuery roleStaffQuery){

        IPage iPage=entityService.pageStaff(page.b(), roleStaffQuery);

        return Result.ok(new PageResult<>(StaffConvert.INSTANCE.convertList(iPage.getRecords()), iPage.getTotal()));
    }

}